package com.gitee.huanminabc.fastboot.load.stage;

import com.gitee.huanminabc.fastboot.common.Order;
import com.gitee.huanminabc.fastboot.load.hook.LifecycleHook;
import com.gitee.huanminabc.fastboot.load.stage.poststage.AppLoadPostStage;
import com.gitee.huanminabc.fastboot.load.stage.prestage.AppLoadPreStage;
import com.gitee.huanminabc.fastboot.load.stage.syncstage.AppLoadSyncStage;

/**
 * @program: netty-web
 * @description:
 * @author: huanmin
 * @create: 2025-04-01 10:46
 **/
public interface AppLoadStage  extends Order {
    //运行
    void run();
    //是否运行
    default boolean isRun(){
        return true;
    }

    static void addAppLoadStage(AppLoadStage stage) {
        if (stage instanceof AppLoadPreStage){
            PreStageLauncher.appLoadStages.add((AppLoadPreStage)stage);
            return;
        }
        if (stage instanceof AppLoadSyncStage){
            SyncStageLauncher.appLoadStages.add((AppLoadSyncStage)stage);
            return;
        }
        if (stage instanceof AppLoadPostStage){
            PostStageLauncher.appLoadStages.add((AppLoadPostStage)stage);
            return;
        }
        throw new IllegalArgumentException("Unknown stage : " + stage);
    }
}
